package com.example.springmall.controller;

import com.example.springmall.common.R;
import com.example.springmall.service.HelloService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/hello")
@RequiredArgsConstructor
public class HelloController {

    private final HelloService helloService;

    @GetMapping
    public R hello(HttpServletRequest request) {
        Integer userId = Integer.valueOf(request.getAttribute("userId").toString());
        System.out.println("userId = " + userId);
        return R.ok(helloService.hello());
    }


} 